package 图形界面;

import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class findSDorm {
    //图二十三框架
    private JFrame frame23=new JFrame("查找界面");
    private JLabel lf1=new JLabel("请输入你要查找同学的名字");
    private JTextField jtfd1=new JTextField(20);
    private JButton jbt1=new JButton("查找");

    //图二十四框架
    private JFrame frame24=new JFrame("查找成功");
    public findSDorm() {
        frame23.setSize(550,400);
        frame23.setLocation(500, 200);
        frame23.setLayout(new FlowLayout());
        frame23.add(lf1);
        frame23.add(jtfd1);
        frame23.add(jbt1);
        jbt1.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                frame23.setVisible(false);
                frame24.setSize(550,120);
                frame24.setLocation(500, 200);
                frame24.setLayout(new FlowLayout());
                String a=jtfd1.getText();
                try {
                    drom101 drom104= drom101.find3(a);
                    String b=drom104.getSname();
                    String c=drom104.getBuiltNum();
                    String d=drom104.getDormNum();
                    String f=drom104.getBedNum();
                    DefaultTableModel dftm2=new DefaultTableModel();
                    dftm2.addColumn("姓名");
                    dftm2.addColumn("栋号");
                    dftm2.addColumn("宿舍号");
                    dftm2.addColumn("床位");
                    dftm2.addRow(new Object[]{b,c,d,f});
                    JTable table2=new JTable(dftm2);
                    JScrollPane jsp = new JScrollPane(table2);
                    frame24.add(jsp);
                } catch (Exception ex) {
                    throw new RuntimeException(ex);
                }
                frame24.setVisible(true);
                frame24.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            }
        });
        frame23.setVisible(true);
        frame23.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}
